import type { DogStatus } from "@/types"
import axios from "axios"
import { onMounted, ref } from "vue"

export default function () {

  const dogList = ref<DogStatus[]>([])

  async function getADog() {
    await axios.get("https://dog.ceo/api/breeds/image/random").then(res => {
      const result = res.data
      dogList.value.push(result)
      return result
    }).catch(err => {
      console.log(err)
    })

    return { message: '', status: 'fail' }
    // return { message: '', status: 'success' }
  }

  onMounted(() => {
    getADog()
  })


  return { getADog, dogList }
}
